﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace GLYFrom.DengLu
{
    public partial class denglu : Form
    {
        public denglu()
        {
            InitializeComponent();
        }

        private void denglu_Load(object sender, EventArgs e)
        {

        }

        private void label6_Click(object sender, EventArgs e)
        {
            DengLu.ZhaoHuiMM from = new ZhaoHuiMM();
            from.Show();
        }

        private void label5_Click(object sender, EventArgs e)
        {
            DengLu.ZhuCe from = new ZhuCe();
            from.Show();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string ZhangHao=this.text_ZhangHao.Text.Trim();
            string MiMa = this.text_MiMa.Text.Trim();
            if (ZhangHao.Length==0 || MiMa.Length==0)
            {
                MessageBox.Show("请将账号密码填写完整...");
            }

            //管理员
            if (this.radio_GLY.Checked)
            {
                DataTable table = DBHelper.select(string.Format("select * from T_GuanLiYuan where ZhangHao='{0}' and MiMa='{1}'",ZhangHao,MiMa));
                if (table.Rows.Count>0)
                {
                    GeRenXX.Id = Convert.ToInt32(table.Rows[0]["GLYId"]);//保存管理员Id
                    GeRenXX.ShenFen = 1;//身份
                    Form1 from = new Form1();
                    from.Show();
                }
                else
                {
                    MessageBox.Show("账号或密码错误...");
                }
            }

            //用户
            else
            {
                DataTable table = DBHelper.select(string.Format("select * from T_YongHu where ZhangHao='{0}' and MiMa='{1}'", ZhangHao, MiMa));
                if (table.Rows.Count > 0)
                {
                    GeRenXX.Id = Convert.ToInt32(table.Rows[0]["YHId"]);//保存用户Id
                    GeRenXX.money = Convert.ToInt32(table.Rows[0]["YuE"]);//保存用户资金
                    GeRenXX.ShenFen =2;//身份
                    DiCi.ZhuYe from = new DiCi.ZhuYe();
                    from.Show();
                }
                else
                {
                    MessageBox.Show("账号或密码错误...");
                }
            }

        }

        private void text_MiMa_TextChanged(object sender, EventArgs e)
        {

        }

        private void bindingSource1_CurrentChanged(object sender, EventArgs e)
        {

        }
    }
}
